#include "PointLight.h"
#include <trax.hpp>
#include "atUtil.h"
#include "RayTracer.h"

#define DEFUALT_INTENSITY 150.5f

namespace AtomTrace{

    PointLight::PointLight():
        pos(0.0f, 1.0f, 0.0f),
        intensity(1.0f, 1.0f, 1.0f)
    {
        
    }

    PointLight::PointLight(int i_addr)
    {
        pos.LoadFromGM(i_addr);
        intensity.Set(1.0f, 1.0f, 1.0f); // assume white now. Feb 24, 2014
        //intensity.Set(105.0f); // for photon map. April 5, 2014
    }


    const PointLight & PointLight::LoadFromGM(int i_addr)
    {
        pos.LoadFromGM(i_addr);
        intensity.Set(DEFUALT_INTENSITY);
        return *this;
    }

    PointLight & PointLight::operator=(const PointLight & other)
    {
        this->pos = other.pos;
        this->intensity = other.intensity;
        return *this;
    }

    const Vector3 PointLight::GetDirection(const Vector3 & objPos) const
    {
        return (pos-objPos).GetNormalize();
    }

    Ray PointLight::RandomPhoton() const
    {
    	Ray pht = RayTracer::CastRay(pos, RandomDirection());

    	return pht;
    }

}// namespace AtomTrace
